package anji.plus.system.mark.mapper;

import anji.plus.system.mark.domain.SysUser;
import anji.plus.system.mark.domain.TaskList;
import anji.plus.system.mark.domain.TaskNodeList;
import anji.plus.system.mark.dto.RankInfo;
import anji.plus.system.mark.vo.IndexQuery;
import anji.plus.system.mark.vo.TaskListVoCompleteUpdate;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 任务表Mapper接口
 * </p>
 *
 * @author luwei
 * @since 2023-11-08
 */
public interface TaskListMapper extends BaseMapper<TaskList> {

    List<TaskList> queryTaskList(@Param("name")String name, @Param("monthFirstDay")LocalDate monthFirstDay, @Param("lastDayOfMonth")LocalDate lastDayOfMonth, @Param("departNum")String departNum);

    //确认审核
    TaskList ConfirmReviewPass(@Param("taskId")String taskId, @Param("confirmReviewUser")String confirmReviewUser, @Param("reviewStatus")String reviewStatus,@Param("confirmReason")String confirmReason,@Param("isChange")String isChange);

    TaskList ConfirmReviewFail(@Param("taskId")String taskId, @Param("confirmReviewUser")String confirmReviewUser, @Param("reviewStatus")String reviewStatus,@Param("confirmReason")String confirmReason,@Param("isChange")String isChange);

    //确认审核流转
    TaskList ConfirmChange(@Param("taskId")String taskId, @Param("changeReviewUser")String changeReviewUser, @Param("reviewStatus")String reviewStatus,@Param("confirmChangeMark")String confirmChangeMark,@Param("isChange")String isChange);

    //完成审核
    TaskList completeReviewPass(@Param("taskId")String taskId, @Param("completeReviewUser")String completeReviewUser, @Param("reviewStatus")String reviewStatus,@Param("completeReason")String completeReason, @Param("isChange")String isChange);

    TaskList completeReviewFail(@Param("taskId")String taskId, @Param("completeReviewUser")String completeReviewUser, @Param("reviewStatus")String reviewStatus,@Param("completeReason")String completeReason, @Param("isChange")String isChange);

    //完成审核流转
    TaskList completeChange(@Param("taskId")String taskId, @Param("changeReviewUser")String changeReviewUser, @Param("reviewStatus")String reviewStatus, @Param("completeChangeMark")String completeChangeMark, @Param("isChange")String isChange);


    //新增任务
    Integer addTask(@Param("taskList")TaskList taskList);

    Integer addTaskNode(@Param("taskNodeList") TaskNodeList taskNodeList);


    List<TaskList> queryNeedReviewTask(@Param("name")String name);

    List<TaskList> queryWaitReviewTask(@Param("name")String name);

    List<TaskList> queryRejectTask(@Param("name")String name);

    void nodeUpdate(@Param("taskId")long taskId,@Param("nodeOrderId")String nodeOrderId, @Param("nodeProgress")String nodeProgress,@Param("nodeScore")Double nodeScore);

    Double taskScoreCount(@Param("taskId")long taskId);

    void taskUpdate(@Param("taskId")long taskId, @Param("taskStatus")String taskStatus, @Param("taskScore")Double taskScore, @Param("completeReviewUser")String completeReviewUser,@Param("reviewTheNote")String reviewTheNote);

//
//    首页-查询用户得分
    Double queryUserScore(@Param("name")String name, @Param("monthFirstDay") LocalDate monthFirstDay, @Param("nextMonthfirstday") LocalDate nextMonthfirstday);

    // 首页-查询用户当月截止的任务数量
    Integer queryUserTaskNum(@Param("name")String name,
                             @Param("monthFirstDay") LocalDate monthFirstDay,
                             @Param("nextMonthfirstday") LocalDate nextMonthfirstday);


    List<RankInfo> userScoreRank(@Param("monthFirstDay") LocalDate monthFirstDay, @Param("nextMonthfirstday") LocalDate nextMonthfirstday);

    //定时任务：更新过期任务
    void jobsUpdateExpiredTask(@Param("currentDate")LocalDate currentDate);

    //首页查询汇总
    IndexQuery indexQuery(@Param("name")String name,
                                @Param("monthFirstDay") LocalDate monthFirstDay,
                                @Param("nextMonthfirstday") LocalDate nextMonthfirstday);

    //    首页-查询用户某月所有任务得分
    List<Double> queryUserAllScore(@Param("name")String name,
                             @Param("monthFirstDay") LocalDate monthFirstDay,
                             @Param("nextMonthfirstday") LocalDate nextMonthfirstday);


    String userAuditTask(String name);

    void completeReviewUpdate(TaskListVoCompleteUpdate taskListVoCompleteUpdate);


    void taskNodeUpdate(@Param("taskId")Long taskId, @Param("nodeOrderId")String nodeOrderId, @Param("nodeProgress")String nodeProgress);


    //查询用户 月工时，默认当月
    Double queryUserScheduleTime(@Param("name")String name, @Param("monthFirstDay") LocalDate monthFirstDay, @Param("nextMonthfirstday") LocalDate nextMonthfirstday);


    String queryUserTaskNumIsEnough(@Param("name")String name, @Param("monthFirstDay") LocalDate monthFirstDay, @Param("nextMonthfirstday") LocalDate nextMonthfirstday);

    void updatePrize(@Param("userName")String userName);

    void updatePunish(@Param("userName")String userName);

}